package com.test.controller;

import com.test.domain.Result;
import com.test.domain.Utils;
import com.test.service.HistoryOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/historyOrder")
public class HistoryOrderController {

    private final HistoryOrderService historyOrderService;

    @Autowired

    public HistoryOrderController(HistoryOrderService historyOrderService) {
        this.historyOrderService = historyOrderService;
    }

    @GetMapping("/getHistoryList")
    public Result getHistoryList(@RequestParam("customerPhoneNumber") String customerPhoneNumber){
        return Utils.success(historyOrderService.getHistoryOrderList(customerPhoneNumber));
    }


    @GetMapping("/getHistoryListM")
    public Result getHistoryListM(@RequestParam("merchantPhoneNumber") String merchantPhoneNumber){
        return Utils.success(historyOrderService.getHistoryOrderListM(merchantPhoneNumber));
    }

    @GetMapping("markMerchant")
    public Result markMerchant(@RequestParam("historyOrderNumber")String historyOrderNumber,
                               @RequestParam("merchantOrderGrade") Integer merchantOrderGrade){

        return Utils.success(historyOrderService.markMerchant(historyOrderNumber,merchantOrderGrade));

    }

    @GetMapping("markDish")
    public Result markMerchant(@RequestParam("historyOrderNumber")String historyOrderNumber,
                               @RequestParam("orderDishGrade") Integer orderDishGrade,
                               @RequestParam("dishNumber")String dishNumber){
        return Utils.success(historyOrderService.markDish(historyOrderNumber,orderDishGrade,dishNumber));
    }


}
